package com.jike.buyi.system.index.dao.impl;

import com.jike.buyi.system.index.domain.UserVo;
import com.jike.buyi.system.index.dao.IndexDao;
import com.jike.buyi.ustils.Md5Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class IndexDaoImpl implements IndexDao {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Override
    public UserVo checkUser(String username, String password) {
        UserVo r= null;
        String sql ="select * from tuser t where t.username=? and password =?";
        List<UserVo> l = jdbcTemplate.query(sql,new Object[]{username, Md5Utils.getPsssWordMd5(password)},new BeanPropertyRowMapper<>(UserVo.class));
        if(l!=null && l.size()>0) r = l.get(0);
        return r;
    }
}
